export default (init = 5, action) => {
    switch (action.type) {
        case 'addLikes':
            return init += action.payload;
        case 'subLikes':
            return init -= action.payload;
        default:
            return init;
    }
};

// 同步
export function addlikesAction(payload) {
    return {
        type: 'addLikes',
        payload
    }
};

export function sublikesAction(payload) {
    return {
        type: 'subLikes',
        payload
    }
};

// 异步
export function asyncAddlikesAction(payload) {
    return dispatch => {
        setTimeout(() => {
            dispatch(addlikesAction(payload))
        }, 1000);
    }
};

export function asyncSublikesAction(payload) {
    return dispatch => {
        setTimeout(() => {
            dispatch(sublikesAction(payload))
        }, 1000);
    }
};


